<?php

namespace Lowpress\PressBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass="Lowpress\PressBundle\Entity\Repository\ItemRepository")
 * @ORM\Table(name="lowpress_item")
 * @ORM\InheritanceType("JOINED")
 * @ORM\DiscriminatorColumn(name="discr", type="string")
 * @ORM\DiscriminatorMap({
 * "youtube" = "\Lowpress\PressExtensionsBundle\Entity\YouTube",
 * "tweet" = "\Lowpress\PressExtensionsBundle\Entity\Tweet",
 * "pinboard" = "\Lowpress\PressExtensionsBundle\Entity\Pinboard",
 * "dribbble" = "\Lowpress\PressExtensionsBundle\Entity\Dribbble",
 * "rss" = "\Lowpress\PressExtensionsBundle\Entity\RSS"
 * })
 */
abstract class Item {

    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @ORM\Column(type="datetime")
     */
    private $created;

    /**
     * @ORM\ManyToMany(targetEntity="Tag", inversedBy="items"))
     */
    private $tags;


    public function __construct()
    {
      $this->tags = new \Doctrine\Common\Collections\ArrayCollection();
    }


    /**
     * Get id
     *
     * @return integer $id
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set created
     *
     * @param DateTime $created
     */
    public function setCreated(\DateTime $created)
    {
        $this->created = $created;
    }

    /**
     * Get created
     *
     * @return DateTime $created
     */
    public function getCreated()
    {
        return $this->created;
    }

    public function getTags()
    {
      return $this->tags;
    }

    public function addTag(Tag $tag)
    {
      $tag->addItem($this);
      $this->tags[] = $tag;
    }

}